package com.example.mysql_mybatis_demo.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.mysql_mybatis_demo.common.utils.PageUtils;
import com.example.mysql_mybatis_demo.common.utils.Query;

import com.example.mysql_mybatis_demo.dao.AttrGroupDao;
import com.example.mysql_mybatis_demo.entity.AttrGroupEntity;
import com.example.mysql_mybatis_demo.service.AttrGroupService;
import org.springframework.transaction.annotation.Transactional;


@Service("attrGroupService")
public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupDao, AttrGroupEntity> implements AttrGroupService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<AttrGroupEntity> page = this.page(
                new Query<AttrGroupEntity>().getPage(params),
                new QueryWrapper<AttrGroupEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    @Transactional
    public void transTestImpl() {
        mid();
    }

    public void mid(){
        AttrGroupEntity attrGroupEntity = new AttrGroupEntity();
        attrGroupEntity.setAttrGroupName("test");
        this.save(attrGroupEntity);
        System.out.println(attrGroupEntity.getAttrGroupId());
        int res = 1/0;
    }

}